﻿namespace TroubleshootingofBeanBagAssistant.lCheck
{
	internal class PingCheck : IDiagnosticCheck
	{
		public string Name => "网络Ping连通性检测";

		public CheckResult Run()
		{
			string[] urls = {
							"www.baidu.com",
							"daohang.qq.com",
							"www.qq.com",
							"www.163.com",
							"www.sina.com.cn",
							"www.taobao.com",
							"www.jd.com",
							"www.bing.com",
							"www.baidu.com",
							"daohang.qq.com",
							"www.qq.com",
							"www.163.com",
							"www.sina.com.cn",
							"www.taobao.com",
							"www.jd.com",
							"www.bing.com",
						};
			// 执行Ping检测
			int errorCount;
			bool isAllOk = NetworkDetectionHelper.MyPing(urls, out errorCount);

			if (isAllOk)
			{
				return new CheckResult
				{
					Title = "网络链接畅通",
					Detail = "所有主机Ping通"
				};
			}
			else
			{
				return new CheckResult
				{
					Title = $"有{errorCount}个主机Ping失败！网络不稳定。",
					Detail = "部分主机Ping失败，建议检查网络环境"
				};
			}
		}

	}
}
